<template>
	<div class="login">
		<div class="login_title">
			<van-icon name="arrow-left" size="22px" style="position: absolute;left: 5px;" @click="back"/><p>登录</p>
		</div>
		<div class="login_main">
		  	<div class="login_logo">
				<img src="../../assets/images/login_logo.png" alt="" />
			</div>
			<div class="login_button">
				<button @click="login">手机号快捷登录</button>
			</div>
		</div>
	</div>
</template>

<script>
	import request from '../../api/request.js'
	import { Toast } from 'vant';
	export default{
		
		name:'login',
		data() {
			return{
				token:""
			}
		},
		methods:{
			back(){
				this.$router.back()
			},
			async login(){
				let res=await request({
					url:'/login',
					method:'post',
					data:{
						account:'13123456789',
						password:'123456'
					}
				})
				// 本地存储token
				localStorage.setItem('token',res.result.token)
				
					
					if(res.msg==='操作成功'){
						Toast.success({
						  message: '登录成功！',
						  duration: 1000,
						  forbidClick: true,
						})
					}
					else{
						Toast.fail({
						  message: '登录失败！',
						  duration: 1000,
						  forbidClick: true,
						})
					}
				
				setTimeout(()=>{
					this.$router.push({
						name:'user',
						query:{
							login_flag:true,
							
						}
					})
				},1500)
				
			}
		}
	}
</script>

<style lang="scss">
	.login{
		width: 100%;
		height: 100%;
		display: flex;
		flex-wrap: wrap;
		
		.login_title{
			width: 100%;
			height: 6%;
			background-color: #F8F8F8;
			display: flex;
			justify-content: center;
			align-items: center;
			p{
				font-size: 30px;
				
			}
		}
		.login_main{
			width: 100%;
			height: 94%;
			
			.login_logo{
				width: 100%;
				height: 50%;
				display: flex;
				justify-content: center;
				align-items: center;
				
			}
		}
		.login_button{
			width: 100%;
			height: 10%;
			display: flex;
			justify-content: center;
			align-items: center;
			button{
				width: 80%;
				height: 60%;
				background-color: #5BB89D;
				border-radius: 80px;
				color: white;
				border: none;
				font-size: 30px;
			}
		}
	}
</style>